#include <iostream>
#include <algorithm>
#include <cstdio>
#include <array>
using namespace std;
#ifdef ONLINE_JUDGE

#define getchar() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2) ? EOF : *p1++)
char buf[1 << 23], *p1 = buf, *p2 = buf, ubuf[1 << 23], *u = ubuf;

#endif
int read() {
	int p = 0, flg = 1;
	char c = getchar();
	while (c < '0' || c > '9') {
		if (c == '-') flg = -1;
		c = getchar();
	}
	while (c >= '0' && c <= '9') {
		p = p * 10 + c - '0';
		c = getchar();
	}
	return p * flg;
}
void write(int x) {
	if (x < 0) {
		x = -x;
		putchar('-');
	}
	if (x > 9) {
		write(x / 10);
	}
	putchar(x % 10 + '0');
}
const int N = 2005, M = 4e6 + 5, dx[5] = {0, 1, 0, -1}, dy[5] = {1, 0, -1, 0};
char strbuf[N];
string mp[N];
array <array <int, N>, N> g, f1, f2;
array <int, M> fa;
int find(int x) {
	if (fa[x] == x) return x;
	else return fa[x] = find(fa[x]);
}
void merge(int x, int y) {
	int fx = find(x),
		fy = find(y);
	if (fx == fy) return;
	fa[fx] = fy;
	return;
}
void Sub1(int n, int m, int q) {
	while (q--) {
		int x_1 = read(), y_1 = read(), x_2 = read(), y_2 = read();
		for (int i = x_1; i <= x_2; i++)
			for (int j = y_1; j <= y_2; j++)
				fa[(i - 1) * m + j] = (i - 1) * m + j;
		for (int i = x_1; i <= x_2; i++) {
			for (int j = y_1; j <= y_2; j++) {
				if (mp[i][j] == '0') continue;
				for (int k = 0; k < 4; k++) {
					int tpi = i + dx[k],
						tpj = j + dy[k];
					if (tpi < x_1 || tpi > x_2 || tpj < y_1 || tpj > y_2) continue;
					if (mp[tpi][tpj] == '0') continue;
					merge((i - 1) * m + j, (tpi - 1) * m + tpj);
				}
			}
		}
		int ans = 0;
		for (int i = x_1; i <= x_2; i++) {
			for (int j = y_1; j <= y_2; j++) {
				if (fa[(i - 1) * m + j] == (i - 1) * m + j &&
					mp[i][j] == '1') ans++;
			}
		}
		write(ans), puts("");


	}
}
void Sub2(int n, int m, int q) {
	
}
int main() {
	freopen("unicom.in", "r", stdin);
	freopen("unicom.out", "w", stdout);
	int n = read(), m = read(), q = read();
	mp[0].resize(2000, '0');
	for (int i = 1; i <= n; i++) {
		scanf("%s", strbuf);
		mp[i] = strbuf;
		mp[i] = "0" + mp[i];
	}
	if (n <= 300 && m <= 300 && q <= 300) Sub1(n, m, q), exit(0);
	if (n <= 100 && m <= 100) Sub2(n, m, q), exit(0);
}
